<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="en">

<head>
<title>${pd.SYSNAME}</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link rel="stylesheet" href="../static/login/bootstrap.min.css" />
<link rel="stylesheet" href="../static/login/css/camera.css" />
<link rel="stylesheet" href="../static/login/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="../static/login/matrix-login.css" />
<link href="../static/login/font-awesome.css" rel="stylesheet" />
<script type="text/javascript" src="../static/js/jquery-1.5.1.min.js"></script>

</head>
<script type="text/javascript">
//发送验证码
    function sendCodes(){
       var email = $("#email").val();
			if ($("#email").val() == "") {
				$("#email").tips({
					side : 2,
					msg : '邮箱不得为空',
					bg : '#AE81FF',
					time : 3
				});
				$("#email").focus();
				return false;
			}else{
			    var reg=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/;
			    if(!reg.test($("#email").val())){
				    $("#email").tips({
						side : 2,
						msg : '邮箱格式不正确',
						bg : '#AE81FF',
						time : 3
					});
					$("#email").focus();
					return false;
			    }
			}
			$.ajax({
				url:'<%=path%>/appregist/sendCodes',
				type:"post",
				data:{"email":email},
				dataType:"json",
				success:function(result){
           		 
           			if(result.code=="300"){
           			    
           				$("#email").tips({
							side : 2,
							msg : result.message,
							bg : '#AE81FF',
							time : 3
				       });
						$("#email").focus();
						return false;
						
           			}else{//验证通过
           				show(120);
           			}
				}
			});
			}
			//设置时间
			function show(time){
			
			   time =time-1;
			   if(time==-1){
			     $("#send_code").attr("disabled",false).css("bgcolor","gray");
			     $("#next_step").attr("disabled",true);
			   }else{
			     $("#send_code").attr("disabled",true);
			     $("#next_step").attr("disabled",false);
			     var mess = "发送验证码("+time+")";
				 document.getElementById("send_code").value=mess;
			   }
			   
			   setTimeout("show("+time+")", 1000);
			}
		
		//确认注册
		function saveRegister(){
			if ($("#email").val() == "") {
				$("#email").tips({
					side : 2,
					msg : '邮箱不得为空',
					bg : '#AE81FF',
					time : 3
				});
				$("#email").focus();
				return false;
			}else{
			    var reg=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/;
			    if(!reg.test($("#email").val())){
				    $("#email").tips({
						side : 2,
						msg : '邮箱格式不正确',
						bg : '#AE81FF',
						time : 3
					});
					$("#email").focus();
					return false;
			    }
			}
			
			if ($("#code").val() == "") {
				$("#code").tips({
					side : 2,
					msg : '验证码不得为空',
					bg : '#AE81FF',
					time : 3
				});
				$("#code").focus();
				return false;
			}
			var password1=$("#password1").val();
           var password2=$("#password2").val();
           if(typeof(password1)=='undefined'||""==password1){
                $("#password1").tips({
					side : 2,
					msg : '密码不得为空',
					bg : '#AE81FF',
					time : 3
				});
				$("#password1").focus();
				return false;
           }else if(typeof(password2)=='undefined'||""==password2){
                $("#password2").tips({
					side : 2,
					msg : '确认密码不得为空',
					bg : '#AE81FF',
					time : 3
				});
				$("#password2").focus();
				return false;
           }
           if(password1!=password2){//两次密码输入的不一致
                $("#password1").tips({
					side : 2,
					msg : '两次输入的密码不一致',
					bg : '#AE81FF',
					time : 3
				});
				return false;
           }
           $.ajax({
				url:"<%=path%>/appregist/sureRegiste",
				type:"post",
				data:$("#appregistForm").serialize(),
				dataType:"json",
				success:function(result){
           		 
           			if(result.code=="300"){
           			    
           				$("#email").tips({
							side : 2,
							msg : result.message,
							bg : '#AE81FF',
							time : 3
				       });
						$("#email").focus();
						return false;
						
           			}else{//验证通过
           				
           				window.location.href="/australia_services/login_toLogin";
           			}
				}
			});
		}
    
    
</script>
<body>
	<div
		style="width:100%;text-align: center;margin: 0 auto;position: absolute;">
		<div id="loginbox">
			<form action="" method="post" name="appregistForm" id="appregistForm">
				<div class="control-group normal_text">
					<h3>
						<img src="../static/login/logo.png" alt="Logo" />
					</h3>
				</div>
				<div class="control-group">
					<div class="controls">
						<div class="main_input_box">
							<span class="add-on bg_lg">
							<i><img height="37" src="../static/login/user.png" /></i>
							</span><input type="text" name="email" id="email" value="" placeholder="请输入用户邮箱" />
						<input type="button" name="send_code" id="send_code" onclick="sendCodes();"  placeholder="发送验证码"/>
						</div>
					</div>
				</div>
				<div class="control-group">
					<div class="controls">
						<div class="main_input_box">
							<span class="add-on bg_ly">
							<i><img height="37" src="../static/login/user.png" /></i>
							</span><input type="text" name="code" id="code" placeholder="请输入验证码" value="" />
						</div>
					</div>
				</div>
				<div class="control-group">
					<div class="controls">
						<div class="main_input_box">
							<span class="add-on bg_ly">
							<i><img height="37" src="../static/login/suo.png" /></i>
							</span><input type="password" name="password" id="password1" placeholder="请输入密码" value="" />
						</div>
					</div>
				</div>
				<div class="control-group">
					<div class="controls">
						<div class="main_input_box">
							<span class="add-on bg_ly">
							<i><img height="37" src="../static/login/suo.png" /></i>
							</span><input type="password" name="password2" id="password2" placeholder="请输入确认密码" value="" />
						</div>
					</div>
				</div>
				<div style="float:left;padding-left:10%;">
					<div style="float: left;margin-top:3px;margin-right:2px;">
						<font color="white">供应商协议</font>
					</div>
					
					<div style="float: left;">
						<input name="form-field-checkbox" id="saveid" type="checkbox"
							onclick="savePaw();" style="padding-top:0px;" />
					</div>
				</div>
				
				<div class="form-actions">
					<div style="width:86%;padding-left:8%;">
						 <span class="pull-center">
						 <a onclick="saveRegister(this);" class="flip-link btn btn-info" id="to-recover">确认注册</a></span>
					</div>
				</div>
			</form>

			<div class="controls">
				<div class="main_input_box">
					<font color="white"><span id="nameerr">Copyright © FH
							2100</span></font>
				</div>
			</div>
		</div>
	</div>
	<div id="templatemo_banner_slide" class="container_wapper">
		<div class="camera_wrap camera_emboss" id="camera_slide">
			<div data-src="../static/login/images/banner_slide_01.jpg"></div>
			<div data-src="../static/login/images/banner_slide_02.jpg"></div>
			<div data-src="../static/login/images/banner_slide_03.jpg"></div>
		</div>
		<!-- #camera_wrap_3 -->
	</div>

	<script type="text/javascript">
	
		
	</script>
	<script>
		//TOCMAT重启之后 点击左侧列表跳转登录首页 
		if (window != top) {
			top.location.href = location.href;
		}
	</script>

	<script src="../static/js/bootstrap.min.js"></script>
	<script src="../static/js/jquery-1.7.2.js"></script>
	<script src="../static/login/js/jquery.easing.1.3.js"></script>
	<script src="../static/login/js/jquery.mobile.customized.min.js"></script>
	<script src="../static/login/js/camera.min.js"></script>
	<script src="../static/login/js/templatemo_script.js"></script>
	<script type="../text/javascript" src="static/js/jquery.tips.js"></script>
	<script type="../text/javascript" src="static/js/jquery.cookie.js"></script>
</body>

</html>